package org.wisdom.data.jpa.support;

import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
import org.wisdom.context.WisdomContextHolder;

import lombok.extern.slf4j.Slf4j;

/**
 * 检索当前进程租户id
 *
 * @author 张智研
 * @date 2022/05/26 21:13
 **/
@Slf4j
public class WisdomCurrentTenantIdentifierResolver implements CurrentTenantIdentifierResolver {

    @Override
    public String resolveCurrentTenantIdentifier() {
        String currentTenantId = WisdomContextHolder.getContext().getTenantId();
        log.info("当前租户->{}", currentTenantId);
        return currentTenantId;
    }

    @Override
    public boolean validateExistingCurrentSessions() {
        return true;
    }
}
